// pages/evaluate/evaluate.js
var that,
  api = new (require('../../utils/api.js')),
  headimg = api.getimgurl(),
  app = getApp(),
  util = new (require('../../utils/util.js'));
Page({

  /**
   * 页面的初始数据
   */
  data: {
    waitingtime: '1',
    isclean: '3',
    attitude: '3',
    orderId: 0,
    isclick: !1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that = this;
    that.setData({ orderId: options.orderid })
  },
  sel(e) {
    let { prop, code } = e.currentTarget.dataset
    that.setData({ [prop]: code })
  },
  evaluation() {
    let { waitingtime, isclean, attitude, orderId, isclick } = that.data
    if (!isclick) {
      that.setData({ isclick: !0 })
      wx.showLoading({
        title: '提交中',
      })
      let data = { wait: waitingtime, clean: isclean, serve: attitude, orderId }
      api.reviewwashfeel(data, res => {
        wx.hideLoading()
        if (res.data.code == 0) {
          wx.showToast({
            title: '评价成功',
            icon: 'none',
            duration: 1000,
          })
          setTimeout(function () {
            that.setData({ isclick: !1 })
            wx.navigateBack()
          }, 1000)
        } else {
          wx.showToast({
            title: '评价失败，请稍后重试',
            icon:'none'
          })
          that.setData({ isclick: !1 })
        }
      })
    }
  },
  toback(){
    wx.navigateBack()
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})